/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.dao;

import java.sql.SQLException;

import cn.itlaobing.model.UserModel;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

/** 
 * ClassName: Dao <br/> 
 * Function: 订单管理Dao类<br/> 
 * date: 2017年11月1日 上午10:53:13 <br/> 
 * 
 * @author lhb
 * @since JDK 1.8 
 */
public class UserDao extends BaseDao {
	//修改登录时间
	public int modifyDate(int id)throws ClassNotFoundException, SQLException{
		QueryRunner qr=new QueryRunner(getDataSource());
		String sql="update tbl_user set lastlogintime=now() where userid=?";
		return qr.update(sql,id);
	}
	//用户登录方法


	public UserModel login(String userName,String userPwd) throws ClassNotFoundException, SQLException {
		String sql="select * from tbl_user where useraccount=? or phone=? AND userpwd=?";
		QueryRunner qr=new QueryRunner(getDataSource());
		BeanHandler<UserModel> beanHandler=new BeanHandler<UserModel>(UserModel.class);
		return qr.query(sql,beanHandler,userName,userName,userPwd);
	}
}
